package com.kb.design.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kb.design.dto.DesignProjectDTO;
import com.kb.design.entity.CustomContact;
import com.kb.design.mapper.postgreSQL.CustomContactMapper;
import com.kb.design.service.CustomContactService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;;

@Service
@DS("slave-1")
public class CustomContactServiceImpl extends ServiceImpl<CustomContactMapper, CustomContact> implements CustomContactService {

    @Resource
    private CustomContactMapper customContactMapper;
    @Override
    public CustomContact getCustomContactByProjectId(DesignProjectDTO projectDTO) {
        LambdaQueryWrapper<CustomContact> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(CustomContact::getProjectId, projectDTO.getProjectId())
                .last("limit 1");
        return customContactMapper.selectOne(queryWrapper);
    }
}
